package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import com.ruoyi.system.domain.SysEnterpriseCertification;
import com.ruoyi.system.domain.parm.SysBusinessActivationParm;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.SysBusiness;
import com.ruoyi.system.service.ISysBusinessService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2024-04-03
 */
@Api(tags = "平台商家用户")
@RestController
@RequestMapping("/business")
public class SysBusinessController extends BaseController
{
    @Autowired
    private ISysBusinessService sysBusinessService;

    /**
     * 查询【请填写功能名称】列表
     */
    @ApiOperation(value = "商家列表")
    @RequiresPermissions("system:business:list")
    @GetMapping("/list")
    public TableDataInfo list(SysBusiness sysBusiness)
    {
        startPage();
        List<SysBusiness> list = sysBusinessService.selectSysBusinessList(sysBusiness);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @ApiOperation(value = "商家导出")
    @RequiresPermissions("system:business:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysBusiness sysBusiness)
    {
        List<SysBusiness> list = sysBusinessService.selectSysBusinessList(sysBusiness);
        ExcelUtil<SysBusiness> util = new ExcelUtil<SysBusiness>(SysBusiness.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @ApiOperation(value = "商家详情")
    @RequiresPermissions("system:business:query")
    @GetMapping(value = "/info")
    public AjaxResult getInfo(@RequestParam(name = "id",required = true) String  id)
    {
        return success(sysBusinessService.selectSysBusinessById(id));
    }


    /**
     * 商家激活
     */
    @ApiOperation(value = "商家激活")
    @RequiresPermissions("system:business:activation")
    @Log(title = "【商家激活】", businessType = BusinessType.UPDATE)
    @PutMapping(value = "/activation")
    public AjaxResult edit(@RequestBody @Valid SysBusinessActivationParm sysBusinessActivationParm)
    {

        SysBusiness sysBusiness = new SysBusiness();
        BeanUtils.copyProperties(sysBusinessActivationParm, sysBusiness);

        return toAjax(sysBusinessService.updateSysBusiness(sysBusiness));
    }


}
